﻿using TbShop.Entity;
using TbShop.Web.Helpers;
using TbShop.Web.Infrastructure.Identity;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace TbShop.Web.Areas.Admin.Models
{
    public class AdministratorViewModels : BaseListViewModel
    {
        public IEnumerable<AdministratorDetailViewModel> ApplicationUsers { set; get; }

        public bool IsAdmin { set; get; }
    }

    public class AdministratorDetailViewModel
    {

        public bool LockoutEnabled { get; set; }
        public DateTime LockoutEndDateUtc { get; set; }
        public string PasswordConfirm { get; set; }
        /// <summary>
        /// 登录账号
        /// </summary>
        [Display(Name = "登录账号")]
        //[RegularExpression(@"^[a-zA-Z][a-zA-Z0-9_]{4,15}$", ErrorMessage = "用户名要字母开头，允许5-16字节，允许字母数字下划线")]
        public string UserName { get; set; }
        /// <summary>
        /// 姓名
        /// </summary>
        public string Name { get; set; }

        [Display(Name = "密码")]
        [DataType(DataType.Password)]
        public string Password { get; set; }

        public string OldRoleId { get; set; }
        [Display(Name = "角色")]
        public string RoleId { get; set; }
        public IEnumerable<SelectListItem> RolesList { get; set; }

        /// <summary>
        /// 头像
        /// </summary>
        public string HeadPortrait { get; set; }
        public string Id { get; set; }
        /// <summary>
        /// 最近登录时间
        /// </summary>
        public DateTime? LastLoginTime { get; set; }
        /// <summary>
        /// 最近登录IP
        /// </summary>
        public string LastLoginIP { set; get; }
        /// <summary>
        /// 登录次数
        /// </summary>
        public int LoginCount { get; set; }
        public bool IsDeleted { set; get; }
        public DateTime CreatedDate { get; set; }
        public string CreatedBy { get; set; }

        public string PasswordMD5 { set; get; }
        public string Address { set; get; }
        public string PhoneNumber { get; set; }
    }

    public class ManageUserViewModel
    {
        [DataType(DataType.Password)]
        [Display(Name = "旧密码")]
        public string OldPassword { get; set; }

        [DataType(DataType.Password)]
        [Display(Name = "新密码")]
        public string NewPassword { get; set; }

        [DataType(DataType.Password)]
        [Display(Name = "确认密码")]
        [System.ComponentModel.DataAnnotations.Compare("NewPassword", ErrorMessage = "{0}两次输入不一致")]
        public string ConfirmPassword { get; set; }
    }
}